var txtLoginId = new VerifyTheForm("txtLoginId", async function (val) {
    // console.log("输出");
    let err = await exists(val);
    // console.log(err)
    if (!val) {
        return "账号不能为空";
    } else if (err.code != 0) {
        return err.msg;
    } else if (err.code == 0) {
        if (err.data) {
            return "该账户已被注册"
        } else {
            return false;
        }
    }
})
let txtNickname = new VerifyTheForm("txtNickname", async function (val) {
    if (!val) {
        return "昵称不能为空"
    } else {
        return false;
    }
})
let txtLoginPwd = new VerifyTheForm("txtLoginPwd", async function (val) {
    if (!val) {
        return "密码不能为空"
    } else {
        return false;
    }
})
let txtLoginPwdConfirm = new VerifyTheForm("txtLoginPwdConfirm", async function (val) {
    if (!val) {
        return "密码不能为空";
    } else if (val != txtLoginPwd.input.value) {
        return "密码不一致";
    } else {
        return false;
    }
})
let froma = document.querySelector(".user-form");
froma.addEventListener("submit", async function (e) {
    e.preventDefault();
    let jg = await VerifyTheForm.validationSucceeded(txtLoginId, txtNickname, txtLoginPwd, txtLoginPwdConfirm);
    if (jg) {
        alert("注册成功，点击确定即将跳转登录页面");
        fromName();
        location.href = "login.html";
    }
})
function fromName() {
    let from = new FormData(froma);
    let obj = Object.fromEntries(from.entries())
    reg(obj);
}